package com.yc.eduservice.mapper;

import com.yc.eduservice.model.entities.CourseEntity;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CourseMapper {
//    添加课程
    @Insert("insert into courses values (null, #{course_name}, #{course_code}, #{teacher_realname}, #{teacher_user_id}, #{section_count}, #{course_time}, #{max_student_count}, #{course_profile}, #{textbook}, #{credits_count},#{all_score},#{pass_score});")
    public int addCourse(CourseEntity courseEntity);
//    编辑课程
    @Update("UPDATE courses SET course_name = #{course_name}, course_code = #{course_code},teacher_realname=#{teacher_realname},teacher_user_id=#{teacher_user_id},section_count=#{section_count},course_time=#{course_time},max_student_count=#{max_student_count},course_profile=#{course_profile},textbook=#{textbook},credits_count=#{credits_count},all_score=#{all_score},pass_score=#{pass_score} WHERE id=#{id};")
    public void editCourse(CourseEntity courseEntity);
//    删除课程
    @Delete("DELETE FROM courses WHERE id = #{id};")
    public int deleteCourse(int id);
//    查看课程
    @Select("SELECT * FROM courses WHERE id = #{id};")
    public CourseEntity viewCourse(int id);
    @Select("SELECT * FROM courses;")
    public List<CourseEntity> allCourses();
}
